package com.findFish.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.system.domain.RobotFishCommands;
import com.findFish.system.service.IRobotFishCommandsService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 机器鱼控制指令Controller
 * 
 * @author admin
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/robot/commands")
public class RobotFishCommandsController extends BaseController
{
    @Autowired
    private IRobotFishCommandsService robotFishCommandsService;

    /**
     * 查询机器鱼控制指令列表
     */
    @PreAuthorize("@ss.hasPermi('system:commands:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotFishCommands robotFishCommands)
    {
        startPage();
        List<RobotFishCommands> list = robotFishCommandsService.selectRobotFishCommandsList(robotFishCommands);
        return getDataTable(list);
    }

    /**
     * 导出机器鱼控制指令列表
     */
    @PreAuthorize("@ss.hasPermi('system:commands:export')")
    @Log(title = "机器鱼控制指令", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotFishCommands robotFishCommands)
    {
        List<RobotFishCommands> list = robotFishCommandsService.selectRobotFishCommandsList(robotFishCommands);
        ExcelUtil<RobotFishCommands> util = new ExcelUtil<RobotFishCommands>(RobotFishCommands.class);
        util.exportExcel(response, list, "机器鱼控制指令数据");
    }

    /**
     * 获取机器鱼控制指令详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:commands:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotFishCommandsService.selectRobotFishCommandsById(id));
    }

    /**
     * 新增机器鱼控制指令
     */
    @PreAuthorize("@ss.hasPermi('system:commands:add')")
    @Log(title = "机器鱼控制指令", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotFishCommands robotFishCommands)
    {
        return toAjax(robotFishCommandsService.insertRobotFishCommands(robotFishCommands));
    }

    /**
     * 修改机器鱼控制指令
     */
    @PreAuthorize("@ss.hasPermi('system:commands:edit')")
    @Log(title = "机器鱼控制指令", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotFishCommands robotFishCommands)
    {
        return toAjax(robotFishCommandsService.updateRobotFishCommands(robotFishCommands));
    }

    /**
     * 删除机器鱼控制指令
     */
    @PreAuthorize("@ss.hasPermi('system:commands:remove')")
    @Log(title = "机器鱼控制指令", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotFishCommandsService.deleteRobotFishCommandsByIds(ids));
    }
}
